import 'package:floor/floor.dart';

import '../entity/user.dart';

@dao
abstract class UserDao {
  @Query('SELECT * FROM UserEntity')
  Future<List<UserEntity>> findAllUsers();

  @Query('SELECT * FROM UserEntity WHERE id = :id')
  Stream<UserEntity?> findUserById(int id);

  @insert
  Future<void> insertUser(UserEntity user);

  @insert
  Future<List<int>> insertUsers(List<UserEntity> user);

  @Update(onConflict: OnConflictStrategy.replace)
  Future<void> updateUser(UserEntity user);

  @delete
  Future<void> deleteUser(UserEntity user);

  @delete
  Future<int> deleteUserList(List<UserEntity> list);

  @Query('delete from UserEntity')
  Future<void> deleteAll();
}
